博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ecshop调用指定分类(包含子分类)下所有产品的评论信息
阅读量:7066 次
发布时间:2019-06-28

本文共 1954 字,大约阅读时间需要 6 分钟。

调用指定分类(包含子分类)下所有产品的评论信息,使用了ecshop系统自带的函数get_children($cat_id)调用指定分类下所有子分类的id,该自带函数在文件include/lib_common.php文件内:

/** * 获得指定分类下的商品评论 * sun04zh3-20130321 * @access   public * @param    integer $cat_id * @return   array */function get_comments_cat_id($cat_id){    $sql = 'SELECT c.id_value, c.user_name, c.content, c.add_time, p.goods_name, p.goods_thumb,p.goods_id  FROM '.             $GLOBALS['ecs']->table('comment') .' AS c '.            ' LEFT JOIN '.$GLOBALS['ecs']->table('goods').' AS p ON p.goods_id = c.id_value '.            ' WHERE c.comment_rank = 5 AND c.status = 1 AND c.id_value in (SELECT g.goods_id FROM '.            $GLOBALS['ecs']->table('goods').'AS g '.'WHERE '.get_children($cat_id).')             ORDER BY c.comment_id DESC LIMIT 5';    $res = $GLOBALS['db']->getAll($sql);    $comment = array();    foreach ($res AS $row)    {        $comment[] = array(                           'id_value' => $row['id_value'],                           'user_name'  => $row['user_name'],                           'short_content'  => sub_str($row['content'],60),                           'content'  => $row['content'],                           'add_time' => date("Y-m-d H:i:s", $row['add_time']),                           'goods_thumb' => $row['goods_thumb'],                           'goods_short_name'  => sub_str($row['goods_name'],30),                           'goods_name'  => $row['goods_name'],                           'url' => build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']),);    }    return $comment;}

category.php文件调用:

$smarty->assign('comment',          get_comments_cat_id($cat_id));

category.dwt文件显示:

 

转载于:https://www.cnblogs.com/shangxia/archive/2013/03/21/2973336.html

你可能感兴趣的文章
python曲线拟合
查看>>
BUAA 2014级数据结构第五次上机 二叉树之数组转换广义表
查看>>
EF执行出错~NotSupportedException
查看>>
Linux & Vim Command Wallpaper
查看>>
Linux常用命令备忘
查看>>
小程序右上角转发分享web-view页面(备份前端网)
查看>>
virtualbox linux虚拟机相关
查看>>
关于.net和java我的见解
查看>>
【Android】设置Dialog点击屏幕不消失
查看>>
ConcurrentDictionary与Dictionary
查看>>
Atom Remote-FTP connecting FTP with SSL/TLS
查看>>
《代码大全》阅读笔记-27-程序规模对构建的影响
查看>>
What is R语言
查看>>
【给你一个承诺 - 玩转 AngularJS 的 Promise】
查看>>
P4962 朋也与光玉
查看>>
关于flash cs4意外退出的问题
查看>>
一道笔试指针题目详解
查看>>
easyui datagrid 绑定从后台得到的复杂的特殊数据结构
查看>>
makefile 字符串处理函数
查看>>
Class Prefix(Xcode6以后设置类前缀)
查看>>